home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok56.lha
/
MultiSelect
/
MultiSelect.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
3KB
|
123 lines
(*---------------------------------------------------------------------------
:Program. MultiSelect.mod
:Author. Fridtjof Siebert
:Address. Nobileweg 67, D-7-Stgt-40
:Shortcut. [fbs]
:Version. 2.0
:Date. 01-May-91
:Copyright. PD
:Language. Oberon
:Translator. Amiga Oberon 2.0
:Contents. Installs Input-Handler that translates midButton to lShift
:Usage. "run MultiSelect" to activate / deactivate MultiSelect
---------------------------------------------------------------------------*)
MODULE MultiSelect;
IMPORT sys: SYSTEM,
e: Exec,
es: ExecSupport,
i: Input,
ie: InputEvent;
(*------ Constants: ------*)
CONST
PortName = "MultiSelect[fbs].Port";
ReplyName = "MultiSelect[fbs].ReplyPort";
(*------ VARS: ------*)
VAR
MyMsg: e.Message;
QuitMessage: e.MessagePtr;
MyPort, OldPort: e.MsgPortPtr;
InputDevPort: e.MsgPortPtr;
InputRequestBlock: e.IOStdReqPtr;
HandlerStuff: e.Interrupt;
HandlerActive, InputOpen: BOOLEAN;
(*------ InputHandler: ------*)
PROCEDURE MyHandler(Ev{8}: ie.InputEventPtr): ie.InputEventPtr; (* $StackChk- $SaveRegs+ *)
VAR
ev: ie.InputEventPtr;
BEGIN
ev := Ev;
WHILE ev#NIL DO
IF ie.midButton IN ev.qualifier THEN
INCL(ev.qualifier,ie.lShift)
END;
ev := ev.nextEvent;
END;
RETURN Ev;
END MyHandler; (* $StackChk= *)
(*------ MAIN: ------*)
BEGIN
(*------ Initialization: ------*)
MyPort := NIL; InputDevPort := NIL; InputRequestBlock := NIL;
HandlerActive := FALSE; InputOpen := FALSE;
(*------ Have we already been started? ------*)
OldPort := e.FindPort(PortName);
IF OldPort#NIL THEN
MyPort := es.CreatePort(ReplyName,0); IF MyPort=NIL THEN HALT(20) END;
MyMsg.node.type := e.message;
MyMsg.replyPort := MyPort;
e.PutMsg(OldPort,sys.ADR(MyMsg)); e.WaitPort(MyPort);
es.DeletePort(MyPort); MyPort := NIL; HALT(0);
END;
MyPort := es.CreatePort(PortName,0); IF MyPort=NIL THEN HALT(20) END;
(*------ Add Inputhandler: ------*)
InputDevPort := es.CreatePort("",0);
IF InputDevPort=NIL THEN HALT(20) END;
InputRequestBlock := es.CreateStdIO(InputDevPort);
IF InputRequestBlock=NIL THEN HALT(20) END;
HandlerStuff.data := NIL;
HandlerStuff.code := sys.VAL(e.PROC,MyHandler);
HandlerStuff.node.pri := 51;
IF e.OpenDevice("input.device",0,InputRequestBlock,LONGSET{})#0 THEN HALT(20) END;
InputOpen := TRUE;
InputRequestBlock.command := i.addHandler;
InputRequestBlock.data := sys.ADR(HandlerStuff);
e.OldDoIO(InputRequestBlock); HandlerActive := TRUE;
(*------ Wait: ------*)
REPEAT e.WaitPort(MyPort); QuitMessage := e.GetMsg(MyPort) UNTIL QuitMessage#NIL;
CLOSE
(*------ Remove Inputhandler: ------*)
IF HandlerActive THEN
InputRequestBlock.command := i.remHandler;
InputRequestBlock.data := sys.ADR(HandlerStuff);
e.OldDoIO(InputRequestBlock);
END;
IF InputOpen THEN e.CloseDevice(InputRequestBlock) END;
IF InputRequestBlock#NIL THEN es.DeleteStdIO(InputRequestBlock) END;
IF InputDevPort#NIL THEN es.DeletePort(InputDevPort) END;
(*------ Remove Port: ------*)
IF MyPort#NIL THEN
e.Forbid();
IF QuitMessage=NIL THEN QuitMessage := e.GetMsg(MyPort) END;
WHILE QuitMessage#NIL DO
e.ReplyMsg(QuitMessage);
QuitMessage := e.GetMsg(MyPort);
END;
es.DeletePort(MyPort);
e.Permit();
END;
END MultiSelect.